<!DOCTYPE html>
<html>
<head>
	<title>日报列表</title>
  <!--Import Google Icon Font-->
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  <!--Import materialize.css-->
  <link type="text/css" rel="stylesheet" href="/css/materialize.min.css"  media="screen,projection"/>
  <style type="text/css">
  	.report-add{
  		margin-top: 1rem;
  	}
  	.warning-totast{
  		border-radius:8px;
  		background-color: #ee6e73;
  		position: fixed;
  		width: 50%;
  		left: 25%;
  		margin-top: 50%;
  	}
  	.item-add{
  		position: fixed;
  		right: 10px;
  		bottom: 10px;
  	}
    p.memo{
      font-size: 0.85em;
    }
  </style>
  <!--Let browser know website is optimized for mobile-->
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>

<body>
	<nav style="background-color: #26a69a;">
    <div class="nav-wrapper">
      <a href="/" class="brand-logo right"><img src="<?=$user['avatar']?>" alt="" style="width: 36px;vertical-align: text-top;" class="circle responsive-img"></a>
      <a href="#" data-target="mobile-demo" class="sidenav-trigger"><i class="material-icons">menu</i></a>
      <ul class="sidenav" id="mobile-demo">
	    <li><a href="/users">员工</a></li>
	    <li><a href="/projects">项目</a></li>
	    <li><a href="/report">上报</a></li>
	    
	  </ul>
    </div>
  </nav>
   
	<div class="container">


	  <div class="row report-add">
	    
<!-- Dropdown Trigger -->
  <a class='dropdown-trigger btn' href='#' data-target='dropdown1'>筛选</a>

  <!-- Dropdown Structure -->
  <ul id='dropdown1' class='dropdown-content'>
    <li class="<?=$user_id=='all'?'active':''?>"><a href="?user_id=all">全部</a></li>
    <?php foreach($all as $fitem):?>
    <li class="<?=$user_id==$fitem['id']?'active':''?>"><a href="?user_id=<?=$fitem['id']?>"><?=$fitem['name']?></a></li>
    <?php endforeach;?>
  </ul>

		  <ul class="collection">

		    <?php $weekarray=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]; 
        foreach($list as $item):?>
		    <li class="collection-item avatar" onclick="return goEdit(<?=$item['id']?>);">
          <i class="material-icons circle green">insert_chart</i>
          <span class="title"><?=$item['username']?></span>
             <?php foreach($item['details'] as $detail):?>
             <p><?=$detail['name']?> <?=$detail['hours']?>H</p>
             <p class="memo flow-text"><?=$detail['memo']?></p>
             <?php endforeach;?>
          <a href="#!" class="secondary-content"><i class="material-icons" style="float:left;">today</i><?php echo $weekarray[date("w",strtotime($item['riqi']))];?>

            <p style="clear:both;"><?=substr($item['riqi'],2)?></p></a>
        </li>
         <?php endforeach;?>
		  </ul>
        

<?php if($pages > 1):?>
        <ul class="pagination">
<?php if($page > 1):?>
<li>
  <a href="?page=1&user_id=<?=$user_id?>">
    <i class="material-icons">chevron_left</i>
  </a>
</li>
<?php endif;?>
<?php  for ($i=$begin; $i <= $end; $i++) { ?>
	<li class="<?=$page==$i?'active':''?>"><a href="?page=<?=$i?>&user_id=<?=$user_id?>"><?=$i?></a></li>
<?php } ?>

<?php if($page < $pages):?>
<li>
  <a href="?page=<?=$pages?>&user_id=<?=$user_id?>">
    <i class="material-icons">chevron_right</i>
  </a>
</li>
<?php endif;?>
  </ul>
<?php endif;?>
	  </div>
        






        <a class="btn-floating btn-large item-add cyan pulse" href="/report/edit"><i class="material-icons">add</i></a>
    </div>

	

  <!--JavaScript at end of body for optimized loading-->
  <script type="text/javascript" src="/js/materialize.min.js"></script>
  <script type="text/javascript">
  	function M_info($msg){
  		M.toast({html: $msg, classes: 'warning-totast',displayLength:2000});
  	}
  	function goEdit(id){
  		window.location.href='/report/edit?id='+id;
  	}
  	

  	document.addEventListener('DOMContentLoaded', function() {
	    var elems = document.querySelectorAll('.sidenav');
	    var instances = M.Sidenav.init(elems, []);
	    M.Dropdown.init(document.querySelector('.dropdown-trigger'));
	    M.FormSelect.init(document.querySelectorAll('select'));
	    M.Datepicker.init(document.querySelectorAll('.datepicker'),{format:'yyyy-mm-dd',
	    	maxDate: new Date(),
	    	defaultDate: new Date(),
	    	setDefaultDate:true,
	    	showClearBtn:true,
	    	autoClose:true,
	    	i18n:{
      cancel: '取消',
      clear: '清除',
      done: '确认',
      previousMonth: '‹',
      nextMonth: '›',
      months: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
      monthsShort:  ['1 月', '2 月', '3 月', '4 月', '5 月', '6 月', '7 月', '8 月', '9 月', '10 月', '11 月', '12 月'],
      weekdays: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
      weekdaysShort: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
      weekdaysAbbrev: ['日', '一', '二', '三', '四', '五', '六'], 
    }});
	  });
  </script>
</body>
</html>